/**
 * 栈解决佩兹糖果盒问题
 * 在不改变原有顺序的情况下 将黄色的糖果移出盒子
 */
const Stack = require("./stackDefine");
const candyBox = ["黄", "红", "绿", "蓝", "红", "黄", "黄", "蓝", "蓝", "青"];
//移出黄色糖果
function removeYellowCandy(candyBox) {
  const stack = new Stack();
  for (let index = candyBox.length - 1; index >= 0; index--) {
    const element = candyBox[index];
    stack.push(element);
  }
  let stack1 = new Stack()
  while(!stack.isEmpty()){
    if(stack.peek() === "黄") stack.pop()
    else {
      stack1.push(stack.pop())
    }
  }
  while(!stack1.isEmpty()){
    stack.push(stack1.pop())
  }
  return stack
}
console.log(removeYellowCandy(candyBox))

